package com.sensePlusVR.activity.mine;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.sensePlusVR.base.BaseActivity;
import com.sensePlusVR.bean.FeedbackListRespDto;
import com.sensePlusVR.bean.FeedbackReplyItem;
import com.sensePlusVR.main.R;
import com.sensePlusVR.utils.AppManager;
import com.sensePlusVR.utils.Constant;
import com.sensePlusVR.utils.DateTimeUtil;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

@ContentView(R.layout.activity_feedback_detail)
public class FeedbackDetailActivity extends BaseActivity{
	//private static final String TAG = FeedbackDetailActivity.class.getSimpleName();
	@ViewInject(R.id.title_bar_title_tv)
	private TextView title_bar_title_tv;
	
	@ViewInject(R.id.feedback_ask_content_tv)
	private TextView feedback_ask_content_tv;
	
	@ViewInject(R.id.feedback_ask_time_tv)
	private TextView feedback_ask_time_tv;
	
	@ViewInject(R.id.feedback_answer_content_tv)
	private TextView feedback_answer_content_tv;
	
	@ViewInject(R.id.feedback_answer_time_tv)
	private TextView feedback_answer_time_tv;
	
	private Integer feedbackId;
	
	@Override
	public void setMyContentView() {
		x.view().inject(this);
	}
	
	@Override
	public void getIntentData() {
		super.getIntentData();
		Intent intent = getIntent();
		if(intent != null){
			Bundle bundle = intent.getExtras();
			if(bundle != null){
				feedbackId = bundle.getInt(Constant.INTENT_FEEDBACK_FEEDBACKID);
			}
		}
		
	}
	
	@Override
	public void beforeView() {
		super.beforeView();
		AppManager.getInstance().addActivity(this);
		title_bar_title_tv.setText(R.string.feedback);
		
	}
	
	@Override
	public void initView() {
		super.initView();
		
		FeedbackListRespDto feedbackListRespDto = FeedbackListRespDto.getFeedbackRespDtoById(feedbackId);
		if(feedbackListRespDto != null){
			
			feedback_ask_content_tv.setText(feedbackListRespDto.getFeedback());
			
			feedback_ask_time_tv.setText(DateTimeUtil.getStandTime(feedbackListRespDto.getCreateTime()));
			
		}
		//MyLog.d(TAG, "feedbackListRespDtos : " + feedbackListRespDtos.toString());
		List<FeedbackReplyItem> feedbackReplyItems = FeedbackReplyItem.getFeedbackReply(feedbackId);
		
		if(feedbackReplyItems != null){
			
			FeedbackReplyItem feedbackReplyItem = feedbackReplyItems.get(0);
			
			if(feedbackReplyItem != null){
				
				feedback_answer_content_tv.setText(feedbackReplyItem.getContent());
				
				feedback_answer_time_tv.setText(DateTimeUtil.getStandTime(feedbackReplyItem.getCreateTime()));
				
			}
			
		}
		
		
	}
	
	
	@Event(value = {R.id.title_bar_left_ib})
	private void setViewOnClick(View view){
		switch (view.getId()) {
		case R.id.title_bar_left_ib:
			AppManager.getInstance().finishActivity(this);
			break;
		}
	}
	
	

}
